<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class ManageController extends CI_Controller {

    function index(){
        session_start();
        $_SESSION['uid']=$_GET['uid'];
        $data = array('uid'=>$_SESSION['uid']);

        $this->load->helper('url');
        $this->load->view('header', $data);
        $this->load->view('manage_book');
        $this->load->view('footer');
    }


    function getall(){
        session_start();
        $user_id = intval($_SESSION['uid']);

        $this->load->model('book_m');
        $result = $this->book_m->searchByUserID($user_id);

        header('Content-Type:text/json');
        echo json_encode($result);
    }

    function del(){
        session_start();
        $book_id = intval($_GET['book_id']);

        $this->load->model('book_m');
        $this->book_m->remove($book_id);

        header('Content-Type:text/json');
        echo json_encode(true);
    }

    function modify(){
        session_start();
        $book_id = intval($_GET['book_id']);

        $this->load->model('book_m');
//        $this->book_m->remove($book_id);
        //  not finished yet

        header('Content-Type:text/json');
        echo json_encode(true);
    }

}